package com.pdd.service.impl;

import com.pdd.beans.Order;
import com.pdd.dao.OrderMapper;
import com.pdd.service.OrderService;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 订单业务实现
 */
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    @Setter
    private OrderMapper orderMapper;

    /**
     * 添加订单信息
     *
     * @param order
     * @return
     */
    public boolean addOrder(Order order) {
        return orderMapper.insertOrder(order)>0;
    }

    /**
     * 删除订单信息
     *
     * @param o_id
     * @return
     */
    public boolean delOrder(String o_id) {
        return orderMapper.deleteOrder(o_id)>0;
    }

    /**
     * 修改订单信息
     *
     * @param order
     * @return
     */
    public boolean uplOrder(Order order) {
        return orderMapper.updateOrder(order)>0;
    }

    /**
     * 查询所有订单信息
     *
     * @return
     */
    public List<Order> getOrder() {
        return orderMapper.selectOrder();
    }

    /**
     * 根据订单号查询用户信息
     *
     * @param o_id
     * @return
     */
    public Order getById(int o_id) {
        return orderMapper.selectById(o_id);
    }
}
